package com.test.pic;

import java.io.File;
import java.io.FileNotFoundException;

import net.tsz.afinal.FinalHttp;
import net.tsz.afinal.http.AjaxCallBack;
import net.tsz.afinal.http.AjaxParams;

import com.badibadi.infos.Results;
import com.badibadi.mytools.Constants;
import com.badibadi.mytools.Utils;
import com.badibadi.uniclubber.R;
import com.badibadi.uniclubber.R.layout;
import com.badibadi.uniclubber.R.menu;

import android.os.Bundle;
import android.os.Environment;
import android.os.Message;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;

public class UpYuYinTestActivity extends Activity {

	protected static final String TAG = "UpYuYinTestActivity";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_up_yu_yin_test);
		
		this.findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Utils.showProgress_hen(UpYuYinTestActivity.this);
				AjaxParams params = new AjaxParams();
				File file = new File(Environment.getExternalStorageDirectory()+"/Recordings/"+"REC001.mp3");

				if(file.exists())
				{
				}
				
				try {
					params.put("info", file);
				} catch (FileNotFoundException e) {
					// TODO Auto-generated catch block
					   
				}
				FinalHttp fh = new FinalHttp();
//				fh.configTimeout(15000);
//				fh.configRequestExecutionRetryCount(3);
				fh.post(Constants.BadiUrl_1 + "Index/toUploadAmr", params,
						new AjaxCallBack<Object>() {
							Message message;
							Bundle bundle;

							@Override
							public void onLoading(long count, long current) {
								// TODO Auto-generated method stub
								super.onLoading(count, current);
								Utils.setProgress_hen((int) count);
							}

							@Override
							public void onSuccess(Object t) {
								// TODO Auto-generated method stub
								// Utils.ExitProgress_hen(context);
								if (t != null) {
								}

//								Results results = Utils.checkResult_NNN(UpYuYinTestActivity.this,
//										(String) t);
//								if (results != null
//										&& !results.getRetmsg().equals("null")) {
//									message = new Message();
//									bundle = new Bundle();
//									message.what = 2000;
//									bundle.putString("path", results.getRetmsg());
//									message.setData(bundle);
//									handler.sendMessage(message);
//								} else {
		//
//								}
							}
						});
			}
		});
		
	}

	

}
